using System;
using System.Collections.Generic;
using System.Text;
using Umdf.ComInterop;
using System.IO;

namespace Umdf.SideShow.Scf.Events
{
    public class ScfNavigationEvent : ScfEvent
    {
        private ScfButton _button;

        protected ScfNavigationEvent()
        {
        }

        public ScfNavigationEvent(BinaryReader reader)
        {
            DeserializeObject(reader);
        }

        public ScfNavigationEvent(Guid applicationId, Guid endpointId, uint previousPage, uint targetPage, ScfButton button)
            : this(applicationId, endpointId, (int) SideShowEvents.SCF_EVENT_IDS.SCF_EVENT_NAVIGATION, previousPage, targetPage, button)
        {
            
        }

        protected ScfNavigationEvent(Guid applicationId, Guid endpointId, int eventId, uint previousPage, uint targetPage, ScfButton button)
            : base(applicationId, endpointId, eventId, previousPage, targetPage)
        {
            _button = button;
        }

        public ScfButton Button
        {
            get { return _button; }
        }

        protected override int EventDataSize
        {
            get { return 12; }
        }

        protected override void WriteEventData(System.IO.Stream s)
        {
            base.WriteEventData(s);
            BinaryWriter writer = new BinaryWriter(s);
            writer.Write((uint)_button);
        }

        protected internal override void DeserializeObject(BinaryReader reader)
        {
            base.DeserializeObject(reader);
            _button = (ScfButton)reader.ReadInt32();
        }

        protected internal override void SerializeObject(BinaryWriter writer)
        {
            base.SerializeObject(writer);
            writer.Write((int)_button);
        }
        
    }
}
